home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
vgakit52.zip
/
BANKS.ASM
next >
Wrap
Assembly Source File
|
1992-10-21
|
21KB
|
1,242 lines
include model.inc
include vesa.inc
;
; VGAKIT Version 5.2b
;
; Copyright 1988,89,90,91,92 John Bridges
; Free for use in commercial, shareware or freeware applications
;
; BANKS.ASM
;
.data?
public curbk
curbk dw ?
public vgamem,bksize
vgamem dw ? ;amount of memory on VGA card in K
bksize dw ? ;size of memory banks in K
public cirrus,everex,acumos,paradise,tseng,trident,t8900
public ativga,aheada,aheadb,oaktech,video7
public chipstech,tseng4,genoa,ncr,compaq,vesa,dactype
cirrus dw ?
everex dw ?
acumos dw ?
paradise dw ?
tseng dw ?
trident dw ?
t8900 dw ?
ativga dw ?
aheada dw ?
aheadb dw ?
oaktech dw ? ;Oak Technology Inc OTI-067 and OTI-077
video7 dw ?
chipstech dw ?
tseng4 dw ?
genoa dw ?
ncr dw ?
compaq dw ?
vesa dw ?
dactype dw ? ; 0 = Normal DAC
; 1 = Sierra SC11481, SC11486, SC11488
; 2 = Sierra SC11485, SC11487, SC11489
; 3 = AT&T ATT20C491
; 4 = ACUMOS ADAC1
first dw ? ;flag so whichvga() is only called once
retval dw ? ;first return value from whichvga()
.data
OSEG equ DS: ;segment override for variable access
public bankadr
if @Codesize
bankadr dw offset _nobank
dw seg _nobank
else
bankadr dw offset _nobank
endif
public vesafunc
vesafunc dw 0
dw 0
vesamodes label word
dw 100h, 640, 400, 8
dw 101h, 640, 480, 8
dw 102h, 800, 600, 4
dw 103h, 800, 600, 8
dw 104h, 1024, 768, 4
dw 105h, 1024, 768, 8
dw 106h, 1280,1024, 4
dw 107h, 1280,1024, 8
dw 10Dh, 320, 200,16
dw 10Eh, 320, 200,16
dw 10Fh, 320, 200,24
dw 110h, 640, 480,16
dw 111h, 640, 480,16
dw 112h, 640, 480,24
dw 113h, 800, 600,16
dw 114h, 800, 600,16
dw 115h, 800, 600,24
dw 116h, 1024, 768,16
dw 117h, 1024, 768,16
dw 118h, 1024, 768,24
dw 119h, 1280,1024,16
dw 11Ah, 1280,1024,16
dw 11Bh, 1280,1024,24
dw 0
.code
public newbank
public whichvga
newbank proc ;bank number is in AX
if @Codesize
jmp dword ptr OSEG[bankadr]
else
jmp OSEG[bankadr]
endif
_tseng:: ;Tseng 3000 series
push ax
push dx
cli
mov OSEG[curbk],ax
and al,7
mov ah,al
shl al,1
shl al,1
shl al,1
or al,ah
or al,01000000b
mov dx,3cdh
out dx,al
sti
pop dx
pop ax
ret
_tseng4:: ;Tseng 4000 series
push ax
push dx
cli
mov OSEG[curbk],ax
mov ah,al
mov dx,3bfh ;Enable access to extended registers
mov al,3
out dx,al
mov dl,0d8h
mov al,0a0h
out dx,al
and ah,15
mov al,ah
shl al,1
shl al,1
shl al,1
shl al,1
or al,ah
mov dl,0cdh
out dx,al
sti
pop dx
pop ax
ret
_trident:: ;Trident
push ax
push dx
push ax
cli
mov OSEG[curbk],ax
mov dx,3ceh ;set pagesize to 64k
mov al,6
out dx,al
inc dl
in al,dx
dec dl
or al,4
mov ah,al
mov al,6
out dx,ax
mov dl,0c4h ;switch to BPS mode
mov al,0bh
out dx,al
inc dl
in al,dx
dec dl
pop ax
mov ah,al
xor ah,2
mov dx,3c4h
mov al,0eh
out dx,ax
sti
pop dx
pop ax
ret
_video7:: ;Video 7
push ax
push dx
push cx
cli
mov OSEG[curbk],ax
and ax,15
mov ch,al
mov dx,3c4h
mov ax,0ea06h
out dx,ax
mov ah,ch
and ah,1
mov al,0f9h
out dx,ax
mov al,ch
and al,1100b
mov ah,al
shr ah,1
shr ah,1
or ah,al
mov al,0f6h
out dx,al
inc dx
in al,dx
dec dx
and al,not 1111b
or ah,al
mov al,0f6h
out dx,ax
mov ah,ch
mov cl,4
shl ah,cl
and ah,100000b
mov dl,0cch
in al,dx
mov dl,0c2h
and al,not 100000b
or al,ah
out dx,al
sti
pop cx
pop dx
pop ax
ret
_paradise:: ;Paradise
push ax
push dx
push ax
cli
mov OSEG[curbk],ax
mov dx,3ceh
mov ax,50fh ;turn off write protect on VGA registers
out dx,ax
pop ax
mov ah,al
mov al,9
out dx,ax
sti
pop dx
pop ax
ret
_acumos:: ;AcuMos
push ax
push dx
push ax
cli
mov OSEG[curbk],ax
mov dx,3c4h ;Sequencer index 6
mov ax,1206h ;turn off write protect on VGA registers
out dx,ax
mov dx,3ceh
pop ax
mov ah,al
mov al,9
out dx,ax
sti
pop dx
pop ax
ret
_chipstech:: ;Chips & Tech
push ax
push dx
push ax
cli
mov OSEG[curbk],ax
mov dx,46e8h ;place chip in setup mode
mov ax,1eh
out dx,ax
mov dx,103h ;enable extended registers
mov ax,0080h
out dx,ax
mov dx,46e8h ;bring chip out of setup mode
mov ax,0eh
out dx,ax
pop ax
mov ah,al
mov al,10h
mov dx,3d6h
out dx,ax
sti
pop dx
pop ax
ret
_ativga:: ;ATI VGA Wonder
push ax
push dx
cli
mov OSEG[curbk],ax
mov ah,al
mov dx,1ceh
mov al,0b2h
out dx,al
inc dl
in al,dx
shl ah,1
and al,0e1h
or ah,al
mov al,0b2h
dec dl
out dx,ax
sti
pop dx
pop ax
ret
_everex:: ;Everex
push ax
push dx
push cx
cli
mov OSEG[curbk],ax
mov cl,al
mov dx,3c4h
mov al,8
out dx,al
inc dl
in al,dx
dec dl
shl al,1
shr cl,1
rcr al,1
mov ah,al
mov al,8
out dx,ax
mov dl,0cch
in al,dx
mov dl,0c2h
and al,0dfh
shr cl,1
jc nob2
or al,20h
nob2: out dx,al
sti
pop cx
pop dx
pop ax
ret
_aheada:: ;Ahead Systems Ver A
push ax
push dx
push cx
cli
mov OSEG[curbk],ax
mov ch,al
mov dx,3ceh ;Enable extended registers
mov ax,200fh
out dx,ax
mov dl,0cch ;bit 0
in al,dx
mov dl,0c2h
and al,11011111b
shr ch,1
jnc skpa
or al,00100000b
skpa: out dx,al
mov dl,0cfh ;bits 1,2,3
mov al,0
out dx,al
inc dx
in al,dx
dec dx
and al,11111000b
or al,ch
mov ah,al
mov al,0
out dx,ax
sti
pop cx
pop dx
pop ax
ret
_aheadb:: ;Ahead Systems Ver A
push ax
push dx
push cx
cli
mov OSEG[curbk],ax
mov ch,al
mov dx,3ceh ;Enable extended registers
mov ax,200fh
out dx,ax
mov ah,ch
mov cl,4
shl ah,cl
or ah,ch
mov al,0dh
out dx,ax
sti
pop cx
pop dx
pop ax
ret
_oaktech:: ;Oak Technology Inc OTI-067 and OTI-077
push ax
push dx
cli
mov OSEG[curbk],ax
and al,15
mov ah,al
shl al,1
shl al,1
shl al,1
shl al,1
or ah,al
mov al,11h
mov dx,3deh
out dx,ax
sti
pop dx
pop ax
ret
_genoa:: ;GENOA GVGA
push ax
push dx
cli
mov OSEG[curbk],ax
mov ah,al
shl al,1
shl al,1
shl al,1
or ah,al
mov al,6
or ah,40h
mov dx,3c4h
out dx,ax
sti
pop dx
pop ax
ret
_ncr:: ;NCR 77C22E
push ax
push dx
cli
mov OSEG[curbk],ax
mov ah,al
mov al,18h
mov dx,3c4h
out dx,ax
mov ax,19h
out dx,ax
sti
pop dx
pop ax
ret
_compaq:: ;Compaq
push ax
push dx
push ax
cli
mov OSEG[curbk],ax
mov dx,3ceh
mov ax,50fh ;unlock extended registers
out dx,ax
pop ax
mov ah,al
mov al,45h
out dx,ax
sti
pop dx
pop ax
ret
_vesa:: ;Vesa SVGA interface
push ax
push bx
push dx
cli
mov OSEG[curbk],ax
mov dx,ax
xor bx,bx
call dword ptr OSEG[vesafunc]
mov dx,OSEG[curbk]
mov bx,1
call dword ptr OSEG[vesafunc]
sti
pop dx
pop bx
pop ax
ret
_nobank::
cli
mov OSEG[curbk],ax
sti
ret
newbank endp
bkadr macro func
mov [func],1
mov word ptr [bankadr],offset _&func
if @Codesize
mov word ptr [bankadr+2],seg _&func
endif
endm
nojmp macro
local lbl
jmp lbl
lbl:
endm
dummyvesa proc far
ret
dummyvesa endp
whichvga proc uses si di es
local vesabuf[512]:byte ; extra large to make up for
; bugs in some VESA VBE's
cmp [first],'FI'
jnz gotest
mov ax,[retval]
ret
gotest: mov word ptr [bankadr],offset _nobank
if @Codesize
mov word ptr [bankadr+2],seg _nobank
endif
mov [vgamem],256
mov [bksize],64
xor ax,ax
mov [curbk],ax
mov [cirrus],ax
mov [everex],ax
mov [paradise],ax
mov [tseng],ax
mov [trident],ax
mov [t8900],ax
mov [ativga],ax
mov [aheada],ax
mov [aheadb],ax
mov [oaktech],ax
mov [video7],ax
mov [chipstech],ax
mov [tseng4],ax
mov [genoa],ax
mov [ncr],ax
mov [compaq],ax
mov [vesa],ax
mov [dactype],ax
mov [first],'FI'
mov si,1 ;flag for SVGA found
mov ax,ss
mov es,ax
lea di,vesabuf[0]
mov ax,4f00h
int 10h
cmp ax,4fh
jnz novesa
mov [bksize],64 ; (